package com.cjy.checkin.controller;

import com.cjy.checkin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
public class ExculxController {
    @Autowired
    private UserService userService;
    @PostMapping(value="user/comment",headers="content-type=multipart/form-data")
    @ResponseBody
    public Map<String ,Object> uploadExcl(HttpServletRequest request, @RequestParam("file") MultipartFile file){
        Map<String ,Object> result = new HashMap<>();
        String path = request.getSession().getServletContext().getRealPath("/");
        try{
            if(!file.isEmpty()){
                result = userService.uploadExcl(file);
            }else {
                result.put("code","1");
                result.put("message","上传文件为空！");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

}
